package com.example.onedemotest.slice;


import com.example.onedemotest.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class TwoSlice extends AbilitySlice {
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_two);
        Text test = (Text) findComponentById(ResourceTable.Id_test);
        int data = intent.getIntParam("Data", 0);
        test.setText("收到的数据"+data);

        Button backBtn= (Button) findComponentById(ResourceTable.Id_backBtn);
        backBtn.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent1 = new Intent();
                intent1.setParam("data",data+5);
                setResult(intent1);
                onBackPressed();
            }
        });
    }
}
